//
//  JIuDianThirdCell.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/21.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "JIuDianThirdCell.h"

@implementation JIuDianThirdCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)loadCell:(NSDictionary *)dataDic
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    //酒店的地址
    _addressLab = [UILabel new];
    _addressLab.textColor = TextBlackGray;
    _addressLab.font = [UIFont systemFontOfSize:12*screenW_6];
    _addressLab.text = dataDic[@"address"];
    _addressLab.numberOfLines = 0;
    [self.contentView  addSubview:_addressLab];
    [_addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView ).offset(10*screenW_6);
        make.top.equalTo(self.contentView.mas_top).offset(15*screenW_6);
        make.width.equalTo(@(SCREENW-140*screenW_6));
    }];
    
    
    //区域的View
    _AdressView = [UIView new];
    [self.contentView addSubview:_AdressView];
    [_AdressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10*screenW_6);
        make.top.equalTo(_addressLab.mas_bottom).offset(15*screenW_6);
        make.width.equalTo(@(SCREENW-80*screenW_6));
        make.height.equalTo(@(25*screenW_6));
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-5*screenW_6);
    }];
    [self addAddress:dataDic];
    
    //导航的View
    _daoHangView = [UIView new];
    [self.contentView addSubview:_daoHangView];
    [_daoHangView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-10*screenW_6);
        make.top.equalTo(self.contentView.mas_top).offset(10*screenW_6);
        make.width.equalTo(@(60*screenW_6));
        make.height.equalTo(@(25*screenW_6));
    }];
    [self addDaHang];
    [_daoHangView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)]];
}

//区域距离
-(void)addAddress:(NSDictionary *)dic
{
    //定位图片
    UIImageView *dingweiImageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 5*screenW_6, 10*screenW_6, 13*screenW_6)];
    dingweiImageV.image = [UIImage imageNamed:@"Main_navi"];
    [_AdressView addSubview:dingweiImageV];
    
    //酒店的名字
     _quAdress = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(dingweiImageV.frame)+5*screenW_6, 5*screenW_6, SCREENW-100*screenW_6, 25*screenW_6)];
    _quAdress.textColor = TextBlackGray;
    _quAdress.font = [UIFont systemFontOfSize:13*screenW_6];
    _quAdress.text = [NSString stringWithFormat:@"%@",dic[@"area"][@"name"]];
    _quAdress.numberOfLines = 0;
    [_quAdress sizeToFit];
    [_AdressView  addSubview:_quAdress];
}
//添加导航
-(void)addDaHang
{
    //定位图片
    UIImageView *dingweiImageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 5*screenW_6,15*screenW_6, 15*screenW_6)];
    dingweiImageV.image = [UIImage imageNamed:@"daohang_icon"];
    [_daoHangView addSubview:dingweiImageV];
    
    //酒店的名字
    UILabel * daohangLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(dingweiImageV.frame)+5*screenW_6, 5*screenW_6, SCREENW-50*screenW_6, 25*screenW_6)];
    daohangLab.textColor = greenColor;
    daohangLab.font = [UIFont systemFontOfSize:14*screenW_6];
    daohangLab.text = @"导航";
    daohangLab.numberOfLines = 0;
    [daohangLab sizeToFit];
    [_daoHangView  addSubview:daohangLab];
}

-(void)click
{
    if (_blcok) {
        _blcok();
    }
}

@end
